import UIComponent from "./UIComponent"
import cjs=createjs
//import createjs from "../../createjs"
export default class ProgressBar extends UIComponent{
    private bg=new cjs.Shape()
    private bar=new cjs.Shape()
    private slider=new cjs.Shape()
    /** 进度，取值范围0-1 */
    private _progress=0
    private _lw=3
    constructor(){
        super()
        this.addChild(this.bg)
        this.addChild(this.bar)
        this.addChild(this.slider)
        this.bar.mask=this.slider
    }
    set progress(value:number){
        this._progress=value
        this.reflush()
    }
    get progress():number{
        return this._progress
    }
    reflush():void {
        this.bg.graphics.clear();
		this.bg.graphics.beginFill("#fe7b00");
		this.bg.graphics.drawRoundRect(0,0,this.width,this.height,this.height/2);
		this.bg.graphics.endFill();
			
		this.bar.graphics.clear();
		this.bar.graphics.beginFill("#ffffff");
		this.bar.graphics.drawRoundRect(this._lw,this._lw,this.width-this._lw*2,this.height-this._lw*2,(this.height-this._lw*2)/2);
		this.bar.graphics.endFill();
			
		this.slider.graphics.clear();
		this.slider.graphics.beginFill("rgba(0,0,0,0)");
		this.slider.graphics.drawRect(this.width*this.progress,0,this.width*(1-this.progress),this.height);
		this.slider.graphics.endFill();
    }
}